class Solution
{
public:
    int maxArea(vector<int> &height)
    {
        int leftBound = 0;
        int rightBound = height.size() - 1;
        int area = (rightBound - leftBound) * min(height[leftBound], height[rightBound]);
        while (leftBound != rightBound)
        {
            if (height[leftBound] < height[rightBound])
            {
                ++leftBound;
            }
            else
            {
                --rightBound;
            }
            int newArea = (rightBound - leftBound) * min(height[leftBound], height[rightBound]);
            area = max(area, newArea);
        }
        return area;
    }
};